package com.ywjt.platformbusiness.order.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.ywjt.platformbusiness.R;
import com.ywjt.platformbusiness.base.BaseActivity;


public class ActivityOrderPostSale extends BaseActivity implements View.OnClickListener {
    private ImageView ivBack;
    private LinearLayout llCallUs;
    private RecyclerView rcView;
   // private Order_Item_Adapter adapter;
    private LinearLayoutManager manager;
  //  private OrderDetail model;

    private String orderNum="";
    private TextView tvGoodsMoney;
    private TextView tvOrdernum;
    private TextView tvOrderCreateTime;
    private TextView tvPayTime;
    private TextView tvAddress;
    private TextView tvName;
    private TextView tvPhone;
    private TextView tvCopy;
    private TextView tvFreight;
    private TextView tvPayType;
    private TextView tvTrack;
    private TextView tvTrackTime;
    private TextView tvCouponMoney;
    private TextView tvRealPrice;
    private LinearLayout llTrack;
    private TextView tvDelete;
    public static void actionStart(Context context,String orderNum) {
        Intent intent = new Intent(context, ActivityOrderPostSale.class);
        intent.putExtra("orderNum",orderNum);
        context.startActivity(intent);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.ivBack:
                finish();
                break;
//            case R.id.llCallUs:
//                //联系我们
//                CallPhoneBottomDialog dialog=new CallPhoneBottomDialog(getContext());
//                dialog.show(getSupportFragmentManager());
//                break;
//            case R.id.tvCopy:
//                //复制订单号到剪切板
//                copyText();
//                break;
//            case R.id.tvDelete:
//                //删除订单
//                deleteOrder();
//                break;
//            case R.id.llTrack:
//                //物流
//                ActivityGoodsTrack.actionStart(ActivityOrderFinish.this,model.getData().getExpressCode(),
//                        model.getData().getExpressNum(),
//                        model.getData().getOrderDetailList().get(0).getGoodsCover(),model.getData().getOrderDetailList().size());
//                break;
        }
    }

    @Override
    protected void init(Bundle savedInstanceState) {
        setAndroidNativeLightStatusBar(true);
    }

    @Override
    protected int setLayoutResourceID() {
        return R.layout.activity_goodsorderdetail_postsale;
    }

    @Override
    protected void initView() {
        orderNum=getIntent().getStringExtra("orderNum");
        ivBack=findViewById(R.id.ivBack);
        ivBack.setOnClickListener(this::onClick);
//        llCallUs=findViewById(R.id.llCallUs);
//        llCallUs.setOnClickListener(this::onClick);
//        rcView=findViewById(R.id.rcView);
//        tvGoodsMoney=findViewById(R.id.tvGoodsMoney);
//        tvOrdernum=findViewById(R.id.tvOrdernum);
//        tvDelete=findViewById(R.id.tvDelete);
//        tvDelete.setOnClickListener(this::onClick);
//        tvOrderCreateTime=findViewById(R.id.tvOrderCreateTime);
//        tvCopy=findViewById(R.id.tvCopy);
//        tvCopy.setOnClickListener(this::onClick);
//        tvPayTime=findViewById(R.id.tvPayTime);
//        tvAddress=findViewById(R.id.tvAddress);
//        tvName=findViewById(R.id.tvName);
//        tvPhone=findViewById(R.id.tvPhone);
//        tvFreight=findViewById(R.id.tvFreight);
//        tvPayType=findViewById(R.id.tvPayType);
//        tvTrack=findViewById(R.id.tvTrack);
//        tvTrackTime=findViewById(R.id.tvTrackTime);
//        tvCouponMoney=findViewById(R.id.tvCouponMoney);
//        tvRealPrice=findViewById(R.id.tvRealPrice);
//        llTrack=findViewById(R.id.llTrack);
//        llTrack.setOnClickListener(this::onClick);
    }

//    //获取订单详情
//    public void getData(){
//        Map<String, String> map = new HashMap<>();
//        map.put("orderNum", orderNum);
//        map.put("userId",getUserId(getContext()));
//        new HttpRequest(getContext()).doPost(UrlConstants.goodsOrder_orderDetail, null, map, OrderDetail.class, new HttpStringCallBack() {
//            @RequiresApi(api = Build.VERSION_CODES.M)
//            @Override
//            public void onSuccess(Object result) {
//                if (result instanceof OrderDetail) {
//                    model=(OrderDetail)result;
//                    setView();
//                }
//            }
//
//            @Override
//            public void onFailure(int code, String msg) {
//                Toast.makeText(cn.xof.xyms.ui.order.activity.ActivityOrderFinish.this,msg,Toast.LENGTH_SHORT).show();
//            }
//        });
//    }
//
//    public void setView(){
//        adapter=new Order_Item_Adapter(model.getData().getOrderDetailList());
//        manager=new LinearLayoutManager(getContext());
//        rcView.setLayoutManager(manager);
//        rcView.setAdapter(adapter);
//
//        tvGoodsMoney.setText("￥"+model.getData().getPrice());
//        tvOrdernum.setText(model.getData().getOrderNum());
//        tvOrderCreateTime.setText(model.getData().getCreateTime());
//        tvPayTime.setText(model.getData().getPayTime());
//        tvAddress.setText(model.getData().getAddress());
//        tvName.setText(model.getData().getName());
//        tvPhone.setText(model.getData().getMobile());
//        tvFreight.setText("￥"+model.getData().getFreight());
////        tvTrack.setText(model.getData().getCurrentExpressStatus());
////        tvTrackTime.setText(model.getData().getCurrentExpressTime());
//        tvCouponMoney.setText("-￥"+model.getData().getCouponsPrice());
//        tvRealPrice.setText("￥"+model.getData().getRealPrice());
//
//
//        switch (model.getData().getPayType()){
//            case 1:
//                tvPayType.setText("支付宝");
//                break;
//            case 2:
//                tvPayType.setText("微信");
//                break;
//            case 3:
//                tvPayType.setText("Apple Pay");
//                break;
//            case 4:
//                tvPayType.setText("积分兑换");
//                break;
//            default:
//                tvPayType.setText("微信");
//                break;
//        }
//    }
//    //实现复制订单号到剪切板
//    public void copyText(){
//        //获取剪贴板管理器：
//        ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
//// 创建普通字符型ClipData
//        ClipData mClipData = ClipData.newPlainText("orderNUm",tvOrdernum.getText().toString().trim());
//// 将ClipData内容放到系统剪贴板里。
//        cm.setPrimaryClip(mClipData);
//        Toast.makeText(cn.xof.xyms.ui.order.activity.ActivityOrderFinish.this,"已成功复制订单号到剪切板",Toast.LENGTH_SHORT).show();
//    }
//
//    //删除订单
//    public void deleteOrder(){
//        Map<String, String> map = new HashMap<>();
//        map.put("orderNum", orderNum);
//        map.put("userId",getUserId(cn.xof.xyms.ui.order.activity.ActivityOrderFinish.this));
//        new HttpRequest(getContext()).doPost(UrlConstants.goodsOrder_removeOrder, "", map, BaseModel.class, new HttpStringCallBack() {
//            @RequiresApi(api = Build.VERSION_CODES.M)
//            @Override
//            public void onSuccess(Object result) {
//                if (result instanceof BaseModel) {
//                    BaseModel bean=(BaseModel)result;
//                    if(bean.getCode()==200){
//                        ToastUtil toastUtil=new ToastUtil(getContext(), R.layout.popu_resetsuccess,"删除订单成功",1);
//                        toastUtil.show();
//                        finish();
//                    }
//                }
//            }
//
//            @Override
//            public void onFailure(int code, String msg) {
//                Toast.makeText(getContext(),msg,Toast.LENGTH_SHORT).show();
//            }
//        });
//    }


    @Override
    protected void initData() {
        //getData();
    }

    @Override
    protected int getTitleBarType() {
        return TITLEBAR_NULL;
    }
}
